﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI;

namespace BLL.sysmanager
{
    public class DepotCategoryService
    {
        protected int page;
        ManagePage mym = new ManagePage();
        public bool DepotCategoryAdd(Page page, string title, int sort_id, string remark)
        {

            ps_depot_category model = new ps_depot_category();
            if (model.Exists(title))
            {
                mym.JscriptMsg(page, "您输入的地区名称已经存在，请检查！", "", "Error");
                return false;
            }

            model.title = title;
            model.sort_id = sort_id;
            model.remark = remark;
            if (model.Add() > 0)
            {
                //mym.AddAdminLog("增加", "添加地区：" + title); //记录日志
                return true;
            }

            return false;
        }

        public bool DepotCategoryUpdate(Page page, int _id, string title, int sort_id, string remark)
        {
            bool result = false;

            ps_depot_category model = new ps_depot_category();
            if (model.Exists(title, _id))
            {
                mym.JscriptMsg(page, "您输入的地区名称已经存在，请检查！", "", "Error");
                return false;
            }
            model.GetModel(_id);

            model.title = title;
            model.sort_id = sort_id;
            model.remark = remark;

            if (model.Update())
            {
                //mym.AddAdminLog("修改", "修改地区:" + title); //记录日志
                result = true;
            }

            return result;
        }
    }
}
